package com.alibaba.citrus.cr.mn.order.center.facade.repository.impl;

import com.alibaba.citrus.cr.common.annotation.RepositoryInvoker;
import com.alibaba.citrus.cr.common.constant.OrderFeaturesKey;
import com.alibaba.citrus.cr.common.exception.RepositoryException;
import com.alibaba.citrus.cr.mn.order.center.common.constants.ForecastConstants;
import com.alibaba.citrus.cr.mn.order.center.facade.function.convert.ForecastOrderRepositoryConverter;
import com.alibaba.citrus.cr.mn.order.center.facade.repository.ForecastOrderLineWriteRepository;
import com.alibaba.cz.base.tool.log.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epoch.app.crforecastsales.domian.forecastorderline.dto.*;
import com.epoch.app.crforecastsales.domian.forecastorderline.model.ForecastOrderLine;
import com.epoch.app.crforecastsales.domian.forecastorderline.service.ForecastOrderLineService;
import com.epoch.app.crforecastsales.enums.ForecastStatusEnum;
import com.epoch.app.crforecastsales.model.dto.BatchUpdateForAnalysisDTO;
import com.epoch.app.crforecastsales.model.dto.BatchUpdateForCloseRequest;
import com.epoch.app.crforecastsales.sdo.ForecastOrderLineSDO;
import com.epoch.app.crforecastsales.service.CrForecastSalesService;
import com.epoch.app.mnordercenter.model.dto.Modifiers;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

@Service("forecastOrderLineWriteRepositoryBiz")
public class ForecastOrderLineWriteRepositoryImpl implements ForecastOrderLineWriteRepository {
    private static final Log log = Log.getLogger(ForecastOrderLineWriteRepositoryImpl.class);
    @Resource
    private ForecastOrderLineService forecastOrderLineService;
    @Resource
    private CrForecastSalesService forecastSalesService;

    /**
     * 保存预报子单
     * @param forecastOrderLineSDO
     * @return
     */
    @Override
    @RepositoryInvoker
    public String save(ForecastOrderLineSDO forecastOrderLineSDO) {
        ForecastOrderLine forecastOrderLine = new ForecastOrderLine();
        if(null!=forecastOrderLineSDO.getStatus()){
            forecastOrderLine.setStatus(forecastOrderLineSDO.getStatus());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getScItemId())){
            forecastOrderLine.setScItemId(forecastOrderLineSDO.getScItemId());//商品id
            //保存子单商品名称
            forecastOrderLine.setScItemTitle(forecastOrderLineSDO.getScItemTitle());

            forecastOrderLine.setProductCode(forecastOrderLineSDO.getItemCode());
            forecastOrderLine.setBarCode(forecastOrderLineSDO.getItemBarCode());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getQuantity())){//数量
            forecastOrderLine.setQuantity(forecastOrderLineSDO.getQuantity());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getDetailRemark())){//备注
            forecastOrderLine.setDetailRemark(forecastOrderLineSDO.getDetailRemark());
        }
        //创建子单先设置其主单id
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getMainOrderId())){
            forecastOrderLine.setMainOrderId(forecastOrderLineSDO.getMainOrderId());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getCreatorId())) {
            forecastOrderLine.setCreatorId(forecastOrderLineSDO.getCreatorId());
            forecastOrderLine.setCreatorCode(forecastOrderLineSDO.getCreatorCode());
            forecastOrderLine.setCreatorName(forecastOrderLineSDO.getCreatorName());
            forecastOrderLine.setCreator(forecastOrderLineSDO.getCreatorId());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getModifierId())) {
            forecastOrderLine.setModifierId(forecastOrderLineSDO.getModifierId());
            forecastOrderLine.setModifierCode(forecastOrderLineSDO.getModofierCode());
            forecastOrderLine.setModifierName(forecastOrderLineSDO.getModifierName());
            forecastOrderLine.setUpdater(forecastOrderLineSDO.getUpdater());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getMainOrderBizId())) {
            forecastOrderLine.setMainOrderBizId(forecastOrderLineSDO.getMainOrderBizId());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getTotalFee())) {
            forecastOrderLine.setTotalFee(forecastOrderLineSDO.getTotalFee());
        }

        forecastOrderLine.setDealStatus(forecastOrderLineSDO.getDealStatus());//队列状态 0
        forecastOrderLine.setSerialNumber(forecastOrderLineSDO.getSerialNumber());//行号 TODO
        forecastOrderLine.setSaleUnit(forecastOrderLineSDO.getSaleUnit());
        forecastOrderLine.setInventoryUnit(forecastOrderLineSDO.getInventoryUnit());//库存单位 TODO
        forecastOrderLine.setInventoryUnitCode(forecastOrderLineSDO.getInventoryUnitCode());
        forecastOrderLine.setSaleUnitcode(forecastOrderLineSDO.getSaleUnitCode());
        forecastOrderLine.setWarehouseArea(forecastOrderLineSDO.getWarehouseArea());
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getUnitConvert())){
            forecastOrderLine.setUnitConvert(forecastOrderLineSDO.getUnitConvert());//单位转换关系
        }
        if (null!=forecastOrderLineSDO.getUnitPrice()){
            forecastOrderLine.setUnitPrice(forecastOrderLineSDO.getUnitPrice());//常规单价
            if (StringUtils.isNotBlank(forecastOrderLineSDO.getQuantity())){
                String quantity = forecastOrderLineSDO.getQuantity();
                forecastOrderLine.setTotalFee(Integer.parseInt(quantity)*forecastOrderLineSDO.getUnitPrice());//常规总金额
            }
        }

        Map<String, Object> features = forecastOrderLineSDO.getFeatures()==null?new HashMap<>():forecastOrderLineSDO.getFeatures();
        features.put(ForecastConstants.GOODS_CODE, forecastOrderLineSDO.getGoodsCode());
        features.put(ForecastConstants.ACTIVITY_TAG,0);
        features.put(ForecastConstants.ACTIVITY_NUMBER,forecastOrderLineSDO.getActivityNumber());
        features.put(ForecastConstants.REPLENISHMENT_ACTIVITY_VERSION,forecastOrderLineSDO.getActivityVersion());
        features.put(ForecastConstants.ACTIVITY_PRICE_REMARK, forecastOrderLineSDO.getActivityPriceRemark());
        features.put(ForecastConstants.REPLENISHMENT_ACTIVITY_REMAINING_FEE,forecastOrderLineSDO.getActivityRemainingFee());
        features.put(ForecastConstants.REPLENISHMENT_ACTIVITY_REMAINING_QUANTITY,forecastOrderLineSDO.getActivityRemainingQuantity());
        features.put(ForecastConstants.REPLENISHMENT_INTENSITY_OF_ACTIVITY_DESC,forecastOrderLineSDO.getIntensityOfActivityDesc());
        features.put(OrderFeaturesKey.SOURCE_UNIT, forecastOrderLineSDO.getSourceUnit());
        features.put(OrderFeaturesKey.SOURCE_QUANTITY, forecastOrderLineSDO.getSourceQuantity());
        features.put(OrderFeaturesKey.SOURCE_PRICE, forecastOrderLineSDO.getSourcePrice());
        forecastOrderLine.setFeatures(JSONObject.toJSONString(features));
        forecastOrderLine.setBizFeatures(forecastOrderLineSDO.getBizFeatures());
        if(StringUtils.isNotEmpty(forecastOrderLineSDO.getActivityName())){
            forecastOrderLine.setActivityName(forecastOrderLineSDO.getActivityName());
        }
        if(StringUtils.isNotEmpty(forecastOrderLineSDO.getActivityCode())){
            forecastOrderLine.setActivityCode(forecastOrderLineSDO.getActivityCode());
        }
        forecastOrderLine.setScItemOutCode(forecastOrderLineSDO.getGoodsCode());
        forecastOrderLine.setProductCode(forecastOrderLineSDO.getItemCode());
        forecastOrderLine.setBarCode(forecastOrderLineSDO.getItemBarCode());
        forecastOrderLine.setCustomerCode(forecastOrderLineSDO.getCustomerCode());
        forecastOrderLine.setCategoryChildCode(forecastOrderLineSDO.getCategoryChildCode());
        forecastOrderLine.setCategoryChildDesc(forecastOrderLineSDO.getCategoryChildDesc());
        forecastOrderLine.setCategoryCode(forecastOrderLineSDO.getCategoryCode());
        forecastOrderLine.setCategoryDesc(forecastOrderLineSDO.getCategoryDesc());
        forecastOrderLine.setFirstCategoryCode(forecastOrderLineSDO.getFirstCategoryCode());
        forecastOrderLine.setFirstCategoryDesc(forecastOrderLineSDO.getFirstCategoryDesc());
        forecastOrderLine.setSecondCategoryCode(forecastOrderLineSDO.getSecondCategoryCode());
        forecastOrderLine.setSecondCategoryDesc(forecastOrderLineSDO.getSecondCategoryDesc());
        forecastOrderLine.setActualTotalReplyAmount(forecastOrderLineSDO.getActualTotalReplyAmount());

        forecastOrderLine.setRefuseReason(forecastOrderLineSDO.getRefuseReason());
        forecastOrderLine.setRefuseReasonCode(forecastOrderLineSDO.getRefuseReasonCode());
        forecastOrderLine.setOuterLineId(forecastOrderLineSDO.getOuterLineId());
        forecastOrderLine.setSourceLineNum(forecastOrderLineSDO.getSourceLineNum());

        forecastOrderLine.setStockLocation(forecastOrderLineSDO.getStockCode());
        forecastOrderLine.setShipWarehouseCode(forecastOrderLineSDO.getShippingWarehouseCode());
        forecastOrderLine.setShippingWarehouseId(forecastOrderLineSDO.getShippingWarehouseId());
        forecastOrderLine.setShippingWarehouseName(forecastOrderLineSDO.getShippingWarehouseName());
        forecastOrderLine.setFactoryCode(forecastOrderLineSDO.getDeliveryFactoryCode());

        //一盘货修改
        forecastOrderLine.setGoodsProductationTime(forecastOrderLineSDO.getGoodsProductationTime());
        forecastOrderLine.setActivityPrice(forecastOrderLineSDO.getActivityPrice());
        forecastOrderLine.setTotalActivityFee(forecastOrderLineSDO.getTotalActivityFee());
        forecastOrderLine.setConfirmQuantity(forecastOrderLineSDO.getConfirmQuantity());
        forecastOrderLine.setInnerProductCode(forecastOrderLineSDO.getInnerProductCode());
        forecastOrderLine.setInnerProductName(forecastOrderLineSDO.getInnerProductName());

        log.info("ForecastOrderLineWriteRepositoryImpl#save forecastOrderLineSDO={}", JSON.toJSONString(forecastOrderLineSDO));
        log.info("ForecastOrderLineWriteRepositoryImpl#save forecastOrderLine={}", JSON.toJSONString(forecastOrderLine));
        CreateForecastOrderLineResponse response = forecastOrderLineService.createForecastOrderLine(forecastOrderLine);
        String lastInsertId = response.getLastInsertId();
        if (StringUtils.isEmpty(lastInsertId)) {
            log.error("ForecastOrderLineWriteRepositoryImpl#save failed");
            throw new RepositoryException("OC-04-003-01-16-007");
        }
        return lastInsertId;
    }

    /**
     *更改预报子单
     */
    @Override
    @RepositoryInvoker
    public Integer modify(ForecastOrderLineSDO forecastOrderLineSDO) {
        ForecastOrderLine forecastOrderLine = new ForecastOrderLine();
        if (forecastOrderLineSDO.getId()==null){
            return null;
        }
        forecastOrderLine.setId(forecastOrderLineSDO.getId());
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getScItemId())){
            forecastOrderLine.setScItemId(forecastOrderLineSDO.getScItemId());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getQuantity())) {
            forecastOrderLine.setQuantity(forecastOrderLineSDO.getQuantity());
        }

        forecastOrderLine.setDetailRemark(forecastOrderLineSDO.getDetailRemark());

        if (StringUtils.isNotBlank(forecastOrderLineSDO.getSaleUnit())) {
            forecastOrderLine.setSaleUnit(forecastOrderLineSDO.getSaleUnit());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getSaleUnitCode())){
            forecastOrderLine.setSaleUnitcode(forecastOrderLineSDO.getSaleUnitCode());
        }
        if (StringUtils.isNotBlank(forecastOrderLineSDO.getUnitConvert())){
            forecastOrderLine.setUnitConvert(forecastOrderLineSDO.getUnitConvert());
        }
        if (null!=forecastOrderLineSDO.getSerialNumber()){
            forecastOrderLine.setSerialNumber(forecastOrderLineSDO.getSerialNumber());
        }
        if (MapUtils.isNotEmpty(forecastOrderLineSDO.getFeatures())) {
            forecastOrderLine.setFeatures(JSONObject.toJSONString(forecastOrderLineSDO.getFeatures()));
        }
        if (Objects.nonNull(forecastOrderLineSDO.getStatus())) {
            // 预报数量 <= 累计回复数量，推进子单状态为已完成
            int actualTotalReplyAmount = forecastOrderLineSDO.getActualTotalReplyAmount() == null ? 0 : forecastOrderLineSDO.getActualTotalReplyAmount();
            int quantity = StringUtils.isBlank(forecastOrderLineSDO.getQuantity()) ? 0 : Integer.parseInt(forecastOrderLineSDO.getQuantity());
            if (quantity <= actualTotalReplyAmount) {
                forecastOrderLine.setStatus(ForecastStatusEnum.COMPLETED.getNumValue());
                forecastOrderLineSDO.setStatus(ForecastStatusEnum.COMPLETED.getNumValue());
            } else {
                forecastOrderLine.setStatus(forecastOrderLineSDO.getStatus());
                forecastOrderLineSDO.setStatus(forecastOrderLineSDO.getStatus());
            }
        }
        if (Objects.nonNull(forecastOrderLineSDO.getTotalFee())) {
            forecastOrderLine.setTotalFee(forecastOrderLineSDO.getTotalFee());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getUnitPrice())){
            forecastOrderLine.setUnitPrice(forecastOrderLineSDO.getUnitPrice());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getMainOrderBizId())){
            forecastOrderLine.setMainOrderBizId(forecastOrderLineSDO.getMainOrderBizId());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getModifierId())){
            forecastOrderLine.setModifierId(forecastOrderLineSDO.getModifierId());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getModifierName())){
            forecastOrderLine.setModifierName(forecastOrderLineSDO.getModifierName());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getModofierCode())){
            forecastOrderLine.setModifierCode(forecastOrderLineSDO.getModofierCode());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getGmtModified())){
            forecastOrderLine.setGmt_modified(forecastOrderLineSDO.getGmtModified());
        }
        if (Objects.nonNull(forecastOrderLineSDO.getGoodsProductationTime())){
            forecastOrderLine.setGoodsProductationTime(forecastOrderLineSDO.getGoodsProductationTime());
        }
        if (StringUtils.isNotBlank(forecastOrderLine.getActivityCode())){
            forecastOrderLine.setActivityCode(forecastOrderLineSDO.getActivityCode());
        }
        if (StringUtils.isNotBlank(forecastOrderLine.getActivityName())){
            forecastOrderLine.setActivityName(forecastOrderLineSDO.getActivityName());
        }
        forecastOrderLine.setStockLocation(forecastOrderLineSDO.getStockCode());
        forecastOrderLine.setFactoryCode(forecastOrderLineSDO.getDeliveryFactoryCode());
        forecastOrderLine.setShipWarehouseCode(forecastOrderLineSDO.getShippingWarehouseCode());
        forecastOrderLine.setShippingWarehouseName(forecastOrderLineSDO.getShippingWarehouseName());
        forecastOrderLine.setBizFeatures(forecastOrderLineSDO.getBizFeatures());
        log.info("forecastOrderLine参数:{}",JSON.toJSONString(forecastOrderLine));
        UpdateForecastOrderLineResponse updateForecastOrderLineResponse = forecastOrderLineService.updateForecastOrderLine(forecastOrderLine);
        log.info("updateForecastOrderLineResponse结果:{}",JSON.toJSONString(updateForecastOrderLineResponse));
        Integer count = updateForecastOrderLineResponse.getCount();
        if (0 == count) {
            log.error("ForecastOrderLineWriteRepositoryImpl#modify_fail");
            throw new RepositoryException("OC-04-003-01-16-010");
        }
        return count;
    }

    @Override
    @RepositoryInvoker
    public Boolean submit(ForecastOrderLineSDO forecastOrderLineSDO) {
        LoadForecastOrderLineRequest loadForecastOrderLineRequest=new LoadForecastOrderLineRequest();
        loadForecastOrderLineRequest.setId(String.valueOf(forecastOrderLineSDO.getId()));
        ForecastOrderLine forecastOrderLine = forecastOrderLineService.loadForecastOrderLine(loadForecastOrderLineRequest);
        forecastOrderLine.setId(forecastOrderLineSDO.getId());
        if(null!=(forecastOrderLineSDO.getStatus())) {
            forecastOrderLine.setStatus(forecastOrderLineSDO.getStatus());
        }
        if(null!=(forecastOrderLineSDO.getDealStatus())) {
            forecastOrderLine.setDealStatus(forecastOrderLineSDO.getDealStatus());
        }
        forecastOrderLine.setModifierId(forecastOrderLineSDO.getModifierId());
        forecastOrderLine.setModifierCode(forecastOrderLineSDO.getModofierCode());
        forecastOrderLine.setModifierName(forecastOrderLineSDO.getModifierName());
        forecastOrderLine.setMainOrderId(forecastOrderLineSDO.getMainOrderId());
//
//        forecastOrderLine.setFeatures(JSONObject.toJSONString(forecastOrderLineSDO.getFeatures()));

        UpdateForecastOrderLineResponse updateForecastOrderLineResponse = forecastOrderLineService.updateForecastOrderLine(forecastOrderLine);
        Integer count = updateForecastOrderLineResponse.getCount();
        if (0 == count) {
            log.error("ForecastOrderLineWriteRepositoryImpl#submit_fail");
            return false;
        }
        return true;
    }
    @Override
    @RepositoryInvoker
    public Boolean update(ForecastOrderLineSDO forecastOrderLineSDO) {
        ForecastOrderLine forecastOrderLine = ForecastOrderRepositoryConverter.toForecastOrderLine(forecastOrderLineSDO);
        Integer count = 0;
        if (StringUtils.isNotBlank(forecastOrderLine.getFeatures())) {
            String features = forecastOrderLine.getFeatures();
            JSONObject jsonObject = JSON.parseObject(features);
            if ("true".equals(jsonObject.get(ForecastConstants.REMOVE_ACTIVITY_ALL_INFO))
                    ||"true".equals(jsonObject.get(ForecastConstants.REMOVE_ACTIVITY_PRICE))) {
                jsonObject.remove(ForecastConstants.REMOVE_ACTIVITY_PRICE);
                forecastOrderLine.setFeatures(jsonObject.toJSONString());
                UpdateForecastOrderLineForNullActivityInfoResponse nullActivityInfoResponse = forecastOrderLineService.updateForecastOrderLineForNullActivityInfo(forecastOrderLine);
                count = nullActivityInfoResponse.getCount();
//                return Objects.nonNull(count) && count != 0;
                return true;
            }
        }
        UpdateForecastOrderLineResponse updateForecastOrderLineResponse = forecastOrderLineService.updateForecastOrderLine(forecastOrderLine);
        count = updateForecastOrderLineResponse.getCount();
        return 0 != count;
    }

    @Override
    @RepositoryInvoker(printLog = false)
    public Boolean updateForAnalysis(ForecastOrderLineSDO forecastOrderLineSDO) {
        ForecastOrderLine forecastOrderLine = ForecastOrderRepositoryConverter.toForecastOrderLine(forecastOrderLineSDO);
        log.info("打印下子单行：{}", forecastOrderLine);
        UpdateForecastOrderLineResponse updateForecastOrderLineResponse = forecastOrderLineService.updateForecastOrderLine(forecastOrderLine);
        Integer count = updateForecastOrderLineResponse.getCount();
        if (0 == count) {
            return false;
        }
        return true;
    }

    @Override
    public Boolean updateForAnalysis(BatchUpdateForAnalysisDTO batchUpdateForAnalysisDTO) {
        boolean success = forecastSalesService.updateForecastOrderReply(batchUpdateForAnalysisDTO).isSuccess();
        boolean lineSuccess = forecastSalesService.updateForecastOrderLineReply(batchUpdateForAnalysisDTO).isSuccess();
        return success && lineSuccess;
    }

    @Override
    public Boolean batchUpdateForClose(BatchUpdateForCloseRequest batchUpdateForCloseRequest) {
        return forecastSalesService.batchUpdateForClose(batchUpdateForCloseRequest).isSuccess();
    }

    @Override
    public Boolean batchUpdateStatusByIds(List<ForecastOrderLineSDO> forecastOrderLineSDOS, Modifiers modifier) {
        List<Long> lineIdList = forecastOrderLineSDOS.stream().map(ForecastOrderLineSDO::getId).collect(Collectors.toList());
        BatchUpdateStatusRequest batchUpdateStatusRequest = new BatchUpdateStatusRequest();
        batchUpdateStatusRequest.setStatus(ForecastStatusEnum.WAITING_FOR_REPLY.getNumValue());
        batchUpdateStatusRequest.setIds(lineIdList);
        batchUpdateStatusRequest.setModifierId(modifier.getId());
        batchUpdateStatusRequest.setModifierCode(modifier.getWorkId());
        batchUpdateStatusRequest.setModifierName(modifier.getName());
        BatchUpdateStatusResponse batchUpdateStatusResponse = forecastOrderLineService.batchUpdateStatus(batchUpdateStatusRequest);
        return 0 != batchUpdateStatusResponse.getEffectRows();
    }

    @Override
    public Boolean batchModify(List<ForecastOrderLineSDO> updateList) {
        return null;
    }

    @Override
    public Boolean batchAdd(List<ForecastOrderLineSDO> addList) {
        return null;
    }

    @Override
    public Boolean batchDelete(List<ForecastOrderLineSDO> deleteList) {
        return null;
    }

    @Override
    public Boolean remove(ForecastOrderLineSDO forecastOrderLineSDO) {
        DeleteRequest deleteRequest = new DeleteRequest();
        deleteRequest.setId(String.valueOf(forecastOrderLineSDO.getId()));
        DeleteResponse delete = forecastOrderLineService.delete(deleteRequest);
        if (Objects.isNull(delete)||1!=delete.getCount()){
            throw new RepositoryException("OC-04-003-01-16-005");
        }
        return Boolean.TRUE;
    }


    @Override
    @RepositoryInvoker
    public Boolean updateReplyQuantity(ForecastOrderLineSDO forecastOrderLineSDO) {
        LoadForecastOrderLineRequest loadForecastOrderLineRequest=new LoadForecastOrderLineRequest();
        loadForecastOrderLineRequest.setId(String.valueOf(forecastOrderLineSDO.getId()));
        ForecastOrderLine forecastOrderLine = forecastOrderLineService.loadForecastOrderLine(loadForecastOrderLineRequest);
        forecastOrderLine.setId(forecastOrderLineSDO.getId());
        forecastOrderLine.setPredictReplyAmount(forecastOrderLineSDO.getPredictReplyAmount());
        forecastOrderLine.setGoodsProductationTime(forecastOrderLineSDO.getGoodsProductationTime());
        forecastOrderLine.setDetailRemark(forecastOrderLineSDO.getDetailRemark());
        UpdateForecastOrderLineResponse updateForecastOrderLineResponse = forecastOrderLineService.updateForecastOrderLine(forecastOrderLine);
        Integer count = updateForecastOrderLineResponse.getCount();
        if (0 == count) {
            return false;
        }
        return true;
    }

}
